gdkdrag-win32.c: Fix drag surface positioning
authorChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 18 Jun 2021 09:58:14 +0000 (17:58 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Fri, 18 Jun 2021 10:07:50 +0000 (18:07 +0800)
Determine the root_x and root_y coordinates of the drag surface by
relying on the coordinates of the surface where the drag is being
carried out, plus the coordinates that we receive from the drag event,
which is in-line with what the X11 backend does.

This will prevent the drag surface from being initially drawn at the
correct position, but jumping towards the top-left corner of the screen
shortly afterwards.

The DnD support will still need some more updates to function correctly
on Windows, but at least this is a small improvement.

Fixes issue #3798.

gdk/win32/gdkdrag-win32.c
gdk/win32/gdkevents-win32.c

index df81a73cec05f5f93b59d508f2d24b8d6db1ae9e..419889ebe1905f8e749dcf63287774a7158a1d33 100644 (file)
@@ -2345,8 +2345,8 @@ gdk_dnd_handle_motion_event (GdkDrag  *drag,
   state = gdk_event_get_modifier_state (event);
   gdk_event_get_position (event, &x, &y);
 
-  x_root = x + _gdk_offset_x;
-  y_root = y + _gdk_offset_y;
+  x_root = event->surface->x + x;
+  y_root = event->surface->y + y;
 
   if (drag_win32->drag_surface)
     move_drag_surface (drag, x_root, y_root);
index 5a17522ae196ab076a92c5213e0b36c7d10f76d9..808354c4ae8979ee6be0deee156e9b718a3d81ac 100644 (file)
@@ -2343,7 +2343,6 @@ gdk_event_translate (MSG *msg,
       current_root_x = (msg->pt.x + _gdk_offset_x) / impl->surface_scale;
       current_root_y = (msg->pt.y + _gdk_offset_y) / impl->surface_scale;
 
-
       if (impl->drag_move_resize_context.op != GDK_WIN32_DRAGOP_NONE)
         gdk_win32_surface_do_move_resize_drag (window, current_root_x, current_root_y);
       else if (_gdk_input_ignore_core == 0)